package edu.tec.mty;

import edu.tec.mty.playModes.*;
import edu.tec.mty.players.*;
import edu.tec.mty.core.*;
import edu.tec.mty.core.modules.*;
import edu.tec.mty.core.modules.models.*;
import java.util.HashMap;

public class Agent {
	
	public static void main(String[] args) {
		HashMap<String, PlayMode> gameStates = new HashMap<String, PlayMode>();
		Controller controller = new Controller();
		controller.setTeamName("Phoenix");
		controller.setTypeOfAgent('p');
		try {
			controller.connect("localhost");
			Commands commands = controller.getReferenceToCommands();
			WorldModelFactory worldModelFactory = controller.getReferenceToWorldModel();
			BallModelFactory ballModelFactory = controller.getReferenceToBallModel();
			Game game = controller.getReferenceToGame();
			Self player = controller.getReferenceToPlayer();
			gameStates.put("before_kick_off", new BeforeKickOff());
			gameStates.put("corner_kick_l", new CornerKickL());
			gameStates.put("corner_kick_r", new CornerKickR());
			gameStates.put("drop_ball", new DropBall());
			gameStates.put("free_kick_l", new FreeKickL());
			gameStates.put("free_kick_r", new FreeKickR());
			gameStates.put("goal_kick_l", new GoalKickL());
			gameStates.put("goal_kick_r", new GoalKickR());
			gameStates.put("goal_l", new GoalL());
			gameStates.put("goal_r", new GoalR());
			gameStates.put("half_time", new HalfTime());
			gameStates.put("kick_in_l", new KickInL());
			gameStates.put("kick_in_r", new KickInR());
			gameStates.put("kick_off_l", new KickOffL());
			gameStates.put("kick_off_r", new KickOffR());
			gameStates.put("offside_l", new OffsideL());
			gameStates.put("offside_r", new OffsideR());
			gameStates.put("play_on", new PlayOn());
			gameStates.put("time_extended", new TimeExtended());
			gameStates.put("time_over", new TimeOver());
			Messi messi = new Messi(commands, game, player);
			boolean running = true;
			while (running) {
				long step = game.getStep();
				BallModel ballModel = ballModelFactory.getBallModel();
				WorldModel worldModel = worldModelFactory.getWorldModel();
				gameStates.get(game.getPlayMode()).perform(messi, ballModel, worldModel);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}
	
}
